package kk.service.impl;

import com.github.pagehelper.PageHelper;
import kk.dao.TravellerDao;
import kk.domain.Traveller;
import kk.service.TravellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TravellerServiceImpl implements TravellerService {

    @Autowired
    private TravellerDao travellerDao;

    @Override
    public List<Traveller> findAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Traveller> travellerList = travellerDao.findAll();
        return travellerList;
    }

    @Override
    public void add(Traveller traveller) {
        travellerDao.add(traveller);
    }

    @Override
    public Traveller findById(Integer id) {
        Traveller traveller = travellerDao.findById(id);
        return traveller;
    }

    @Override
    public void update(Traveller traveller) {
        travellerDao.update(traveller);
    }

    @Override
    public List<Traveller> findByName(String name, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Traveller> travellerList = travellerDao.findByName(name);
        return travellerList;
    }

}
